<?

$sql    = "SELECT * FROM `pa_training` WHERE `tr_showtop`=1 ORDER BY tr_id";
$result = $DB->query($sql);

while($list = $DB->fetch_array($result)){
   $data[] = $list;
}

if(ACT==1){
	$dp = array_rand($data, 1);
	$datalist[0]  = $data[$dp] ;
	unset($data);
	$data = $datalist;
}else{
	$dp = array_rand($data, 3);
	foreach($dp as $key=>$value){
	$datalist[$key] = $data[$value];
	//print_r($data);
	}
	unset($data);
    $data = $datalist;
}
$smarty->assign("traindb",$data);
?>